<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <#include "/comm/module-edit.ftl"/>
</head>
<style type="text/css">

</style>
<body>
<div class="layui-div-body">
    <div class="layui-fluid layui-div-edit">
        <form class="layui-form layui-form-pane" autocomplete="off">
            <div class="layui-form-item">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-inline">
                    <input type="text" name="name" placeholder="请输入姓名" class="layui-input" value="${info.name!}" lay-verify="required">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">手机号码</label>
                <div class="layui-input-inline">
                    <#if info._id ==''>
                        <input type="text" name="phone" placeholder="请输入手机号码" class="layui-input" lay-verify="required|phone" maxlength="11">
                    <#else>
                        <input type="text" disabled class="layui-input"
                               value="${info.phone!}">
                    </#if>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">下载权限</label>
                <div class="layui-input-block">
                    <input type="checkbox" id="editDown" name="editDown" value="1"
                           <#if info.editDown =='1'>checked</#if>
                           lay-skin="switch" lay-filter="switchTest"
                           title="ON|OFF">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">用户选择</label>
                <div class="layui-input-block">
                    <div id="user-transfer"></div>
                </div>
            </div>

            <div class="layui-form-item">
                <button class="layui-btn" lay-submit="" lay-filter="save">立即提交
                </button>
                <#if info._id ==''>
                    <button type="reset" class="layui-btn layui-btn-primary" id="btn-reset">重置</button>
                </#if>
                <input type="hidden" id="_id" name="_id" value="${info._id}"/>
            </div>
        </form>
    </div>
</div>
<script>

    layui.use(['edit'], function () {
        let edit = layui.edit, $ = layui.$;
        // 数据
        var users = '${map.users!}'
        var checkUsers = '${map.checkUsers!}'
        var transfer = layui.transfer;
        // 渲染
        transfer.render({
            elem: '#user-transfer',
            id: 'user-transfer',
            title: ['未选账号', '已选账号'],  //自定义标题
            data: JSON.parse(users),
            value: JSON.parse(checkUsers)
        });
        edit.render(function (obj) {
            var getData = transfer.getData('user-transfer'); // 获取右侧数据
            obj["users"] = jsonString(getData);
            save(obj)
        });
    });
</script>
</body>

</html>
